<!doctype html>
<html>

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>底部导航</title>
    <link rel="stylesheet" type="text/css" href="./css/api.css" />
    <link rel="stylesheet" type="text/css" href="./css/style.css" />
    <link rel="stylesheet" type="text/css" href="css/binge.css" />
    <script type="text/javascript" src="./script/jquery-1.9.1.min.js"></script>
    <script type="text/javascript" src="./script/mobile.js"></script>

    <script type="text/javascript">
        window['adaptive'].desinWidth = 750;
        window['adaptive'].baseFont = 28;
        window['adaptive'].maxWidth = 750;
        window['adaptive'].init();
    </script>
</head>

<body>
    <div id="wrap" class="flex-wrap">
        <div id="header" style="height: 50px;">
        </div>
        <div id="main" class="flex-con">

        </div>
    </div>

    <div id="footer" class="border-t">
        <div class="foot-padding"></div>
        <ul class="flex-wrap">
            <li tapmode="hover" onclick="randomSwitchBtn( this );" class="flex-con active">首页</li>
            <li tapmode="hover" onclick="randomSwitchBtn( this );" class="flex-con">圈子</li>
            <li tapmode="hover" onclick="randomSwitchBtn( this );" class="flex-con">
                <div class="school-logo">
                    <img src="./image/school-icon.png" alt="">
                </div>
            </li>
            <li tapmode="hover" onclick="randomSwitchBtn( this );" class="flex-con">赛事</li>
            <li tapmode="hover" onclick="randomSwitchBtn( this );" class="flex-con">我的</li>
        </ul>
    </div>

</body>

</html>
<script type="text/javascript" src="script/api.js"></script>
<script type="text/javascript" src="script/common.js"></script>
<script type="text/javascript">
    apiready = function() {
        $api.fixStatusBar($api.dom('#header'));
        api.setStatusBarStyle({
            style: 'dark',
            color: '#fff'
        });
        funIniGroup();
    }

    function funIniGroup() {
        var eFootLis = $api.domAll('#footer li');
        var frames = [];
        for (var i = 0, len = eFootLis.length; i < len; i++) {
            if(i == 0){
              frames.push({
                  name: 'frame0' + i,
                  url: './html/index/frame0.html',
                  bgColor: 'rgba(255,255,255)',
                  bounces: true
              })
            }else if(i==1) {
              frames.push({
                  name: 'frame1',
                  url: './html/circle/frame1.html',
                  bgColor: 'rgba(255,255,255)',
                  bounces: true
              })
            }else if(i==2) {
              frames.push({
                  name: 'frame2',
                  url: './html/school/frame2.html',
                  bgColor: 'rgba(255,255,255)',
                  bounces: true
              })
            }else if(i==3) {
              frames.push({
                  name: 'frame3',
                  url: './html/match/frame3.html',
                  bgColor: 'rgba(255,255,255)',
                  bounces: true
              })
            }else if(i==4) {
              frames.push({
                  name: 'frame4',
                  url: './html/member/frame4.html',
                  bgColor: 'rgba(255,255,255)',
                  bounces: true
              })
            }

        }
        console.log(frames)
        console.log(JSON.stringify(eFootLis))
        api.openFrameGroup({
            name: 'group',
            scrollEnabled: false,
            rect: {
                x: 0,
                // y: $api.dom('header').offsetHeight,
                y: 0,
                w: api.winWidth,
                h: $api.dom('#main').offsetHeight
            },
            index: 0,
            frames: frames
        }, function(ret, err) {
            console.log(JSON.stringify(ret));
        });
        console.log(1);
    }

    // 随意切换按钮
    function randomSwitchBtn(tag) {
        if (tag == $api.dom('#footer li.active')) return;
        var eFootLis = $api.domAll('#footer li');
        // eHeaderLis = $api.domAll('header li'),
        var index = 0;
        for (var i = 0, len = eFootLis.length; i < len; i++) {
            if (tag == eFootLis[i]) {
                index = i;
            } else {
                $api.removeCls(eFootLis[i], 'active');
                // $api.removeCls(eHeaderLis[i], 'active');
            }
        }
        $api.addCls(eFootLis[index], 'active');
        // $api.addCls( eHeaderLis[index], 'active');
        api.setFrameGroupIndex({
            name: 'group',
            index: index,
            reload: true
        });
    }
</script>
